import java.util.Hashtable;

public class ShapeCache {
    //Hashtable ：线程安全，方法被synchronized修饰。key、value不允许有 null
    private static Hashtable<String, Shape> shapeMap = new Hashtable<String, Shape>();


    public static Shape getShape(String id) {
        return (Shape)shapeMap.get(id).clone();
    }

    public static void loadShapeProperty(){
        CircleShape circle = new CircleShape();
        circle.setId("1");
        shapeMap.put(circle.getId(), circle);

		Rectangle rectangle = new Rectangle();
        rectangle.setId("2");
        shapeMap.put(rectangle.getId(), rectangle);

        Square square = new Square();
        square.setId("3");
        shapeMap.put(square.getId(), rectangle);
    }

}
